package com.baizhi.controller;

import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("selectUsers")
    @ResponseBody
    public Map selectUsers(){
        Map map = new HashMap();
        List<User> users = userService.selectUser();
        map.put("code",0);
        map.put("data",users);
        return map;
    }

    @RequestMapping("updateUser")
    @ResponseBody
    public Map updateUser(Integer id){
        System.out.println("update parm="+id);
        Map map = new HashMap();
        userService.updateUser(id);
        map.put("flag",true);
        return map;
    }
}
